package com.anbinh.doctor.adapter;

import java.util.List;

import android.content.Context;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.anbinh.doctor.R;
import com.anbinh.doctor.model.SuggestNamePatient.PatientSuggest;

public class AutoCompleteAdapter extends ArrayAdapter<PatientSuggest> {
	private int resource;
	private LayoutInflater layoutInflater;
	private List<PatientSuggest> listData;

	public AutoCompleteAdapter(Context mContext, int resource, List<PatientSuggest> models) {
		super(mContext, resource, models);
		this.resource = resource;
		this.listData = models;
		layoutInflater = LayoutInflater.from(mContext);
	}

	public class ViewHolder {
		public TextView lblTitle;
		public ImageView icon;

	}

	@Override
	public PatientSuggest getItem(int position) {
		return listData.get(position);
	}

	@Override
	public View getView(final int position, View convertView, ViewGroup parent) {
		ViewHolder viewHolder;
		if (convertView == null) {
			viewHolder = new ViewHolder();
			convertView = layoutInflater.inflate(resource, null, true);

			viewHolder.lblTitle = (TextView) convertView
					.findViewById(R.id.textViewItem);


			convertView.setTag(viewHolder);

		} else {
			viewHolder = (ViewHolder) convertView.getTag();
		}
		PatientSuggest item = getItem(position);
		Log.d("lblTitle","lblTitle");
		viewHolder.lblTitle.setText(item.getSent_by_name());

		return convertView;
	}
}
